<?php
namespace Plu\Library\Models\Platform\Media;

use Phalcon\Mvc\Model,
    Phalcon\Db\Column;

class QCloudTranscode extends Model 
{
    public $LiveId;
    public $FileId;
    public $StreamId;
    public $Definition;
    public $Url;
    public $Size;
    public $Container;
    public $Md5;
    public $Bitrate;
    public $Width;
    public $Height;
    public $Duration;
    public $Creater;
    public $CreateTime;
    public $Updater;
    public $UpdateTime;


    public function initialize() {
        $this->setReadConnectionService('db.platform.slave');
        $this->setWriteConnectionService('db.platform'); 
    }

    public function getSource() {
        return 'QCloudTranscode';
    }

    static public function getTranscodeItem($fileId, $isArray = true) {

        $where = [
            "FileId = :fileId: AND Definition = :code: ORDER BY Id DESC",
            "bind" => [
                'fileId' => $fileId,
                'code'   => 9
            ],
        ];

        $item = self::findFirst($where);

        if ($item) {
            if ($isArray) {
                $item = $item->toArray();
            }
            return $item;
        }

        return false;

    }





}
